import request from '@/utils/request'

// 查询报表定义列表
export function listReport(query) {
  return request({
    url: 'ldzl-rpt/rpt/definition/list',
    method: 'get',
    params: query
  })
}

// 查询报表定义详细
export function getReport(reportId) {
  return request({
    url: 'ldzl-rpt/rpt/definition/' + reportId,
    method: 'get'
  })
}

// 新增报表定义
export function addReport(data) {
  return request({
    url: 'ldzl-rpt/rpt/definition',
    method: 'post',
    data: data
  })
}

// 修改报表定义
export function updateReport(data) {
  return request({
    url: 'ldzl-rpt/rpt/definition',
    method: 'put',
    data: data
  })
}

// 删除报表定义
export function delReport(reportId) {
  return request({
    url: 'ldzl-rpt/rpt/definition/' + reportId,
    method: 'delete'
  })
}

// 导出报表定义
export function exportReport(query) {
  return request({
    url: 'ldzl-rpt/rpt/definition/export',
    method: 'get',
    params: query
  })
}

// 获取报表设计信息
export function getReportDesign(reportId) {
  return request({
    url: 'ldzl-rpt/rpt/design/' + reportId,
    method: 'get'
  })
}

// 保存报表设计
export function saveReportDesign(data) {
  return request({
    url: 'ldzl-rpt/rpt/design',
    method: 'post',
    data: data
  })
}

// 获取报表设计历史版本
export function getDesignHistory(reportId) {
  return request({
    url: 'ldzl-rpt/rpt/design/history/' + reportId,
    method: 'get'
  })
}

// 执行SQL预览
export function previewSql(data) {
  return request({
    url: 'ldzl-rpt/rpt/design/preview',
    method: 'post',
    data: data
  })
}

// 获取报表参数
export function getReportParameters(reportId) {
  return request({
    url: 'ldzl-rpt/rpt/parameter/list/' + reportId,
    method: 'get'
  })
}

// 保存报表参数
export function saveReportParameters(data) {
  return request({
    url: 'ldzl-rpt/rpt/parameter/save',
    method: 'post',
    data: data
  })
}

// 执行报表
export function executeReport(reportId, params) {
  return request({
    url: 'ldzl-rpt/rpt/viewer/' + reportId,
    method: 'get',
    params: params
  })
}

// 导出报表数据
export function exportReportData(reportId, params) {
  return request({
    url: 'ldzl-rpt/rpt/viewer/export/' + reportId,
    method: 'get',
    params: params,
    responseType: 'blob'
  })
} 